package io.github.wanggit.antrpc.commons.breaker;

import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import io.github.wanggit.antrpc.commons.config.CircuitBreakerConfig;
import io.github.wanggit.antrpc.commons.config.IConfiguration;
import io.vavr.CheckedFunction0;

import java.util.function.Consumer;
import java.util.function.Function;

public interface IResilience4jCircuitBreakerContainer {

    void reInitGlobalConfig(IConfiguration configuration);

    void reInitInterfaceConfig(IConfiguration configuration);

    CircuitBreaker.State getState(String callUniqueKey);

    Object run(
            String interfaceName,
            String callUniqueKey,
            CheckedFunction0<Object> checkedFunction0,
            Consumer<? super Throwable> consumer,
            Function<? super Throwable, ?> onFailFunction);

    CircuitBreakerConfig getCircuitBreakerConfig(String interfaceName);
}
